package com.tckdq.tcc.feign;

import com.tckdq.tcc.doc.CourseDoc;
import com.tckdq.tcc.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class SearchFeignFallbackFactory implements FallbackFactory<SearchFeignClient> {

    @Override
    public SearchFeignClient create(Throwable throwable) {
        return new SearchFeignClient() {
            @Override
            public JsonResult saveCourse(CourseDoc doc) {
                throwable.printStackTrace();
                return JsonResult.error("搜索服务不可用");
            }

            @Override
            public JsonResult deleteCourse(Long id) {
                throwable.printStackTrace();
                return JsonResult.error("删除es搜索服务失败");
            }
        };
    }
}
